export default {
  methods: {
    async onRefresh() {
      this.finish = false;
      this.page = 1;
      this.dataList = [];
      await this.loadMore();
      this.isLoading = false;
    },
    async loadMore(cb) {
      cb && cb()

      if (this.finish) {
        return;
      }
      this.finish = true
      return await this.findList({ page: this.page }).then(res => {
        if (res.code == 200) {
          if (res.data.length > 0) {
            this.dataList = [...this.dataList, ...res.data];
          }
          if (res.data.length < 15) {
            this.finish = true;
          } else {
            setTimeout(() => {
              this.finish = false;
              this.page++;
            }, 500)

          }
        }
      });
    },
  },

  data() {
    return {
      page: 1,
      dataList: [],
      finish: false,
      isLoading: false
    }
  }
}